<!-- 2017-12-4 14:24:12 | 修改 木遥（微信:  http://marsgis.cn/weixin.html ） -->
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1.0,maximum-scale=1.0" />
    <meta name="apple-touch-fullscreen" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="x5-fullscreen" content="true" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    <!-- 标题及搜索关键字 -->
    <meta name="keywords" content="火星科技,cesium,3D,GIS,marsgis,三维,地球,地图,开发,框架,系统,示例,资料,模型,离线,外包,合肥,安徽,中国" />
    <meta
      name="description"
      content="火星科技 合肥火星 合肥火星科技 合肥火星科技有限公司 leaflet leaflet框架 leaflet开发 cesium cesium开发 cesium框架 三维 地球 模型  gis marsgis 地图离线 地图开发 地图框架 地图外包 框架 开发 外包  地图离线 二维地图 三维地图 全景漫游 地理信息系统 云GIS 三维GIS GIS平台 WebGIS"
    />

    <link rel="shortcut icon" type="image/x-icon" href="/img/favicon/favicon.ico" />
    <title>剖面分析 | Mars3D | 三维地图 | 火星科技 | 合肥火星科技有限公司</title>

    <script
      type="text/javascript"
      src="/lib/include-lib.js"
      libpath="/lib/"
      include="jquery,layer,toastr,font-awesome,bootstrap,layer,haoutil,mars3d,echarts"
    ></script>

    <link href="/css/style.css" rel="stylesheet" />
    <style>
      .sectionChars {
        display: none;
        width: calc(100% - 300px);
        height: 200px;
        top: auto;
        left: 56px;
        bottom: 30px;
      }
    </style>
  </head>

  <body class="dark">
    <div id="mars3dContainer" class="mars3d-container"></div>

    <!-- 面板 -->
    <div class="infoview">
      <span style="color: #cad1d1">提示：单击下面按钮激活绘制，按提示操作即可。</span>
      <br />

      <input type="button" class="btn btn-primary" value="剖面" onclick="measureSection()" />
      <input type="button" class="btn btn-info" value="清除" id="clearAll" />
    </div>

    <div id="sectionChars" class="infoview sectionChars">
      <div id="echartsView1" style="width: 100%; height: 100%"></div>
    </div>

    <!-- 切换视角到模型或地形（山区）的快捷按钮 -->
    <script type="text/javascript" src="/js/center_terrain_3dtiles.js"></script>

    <script src="/js/common.js"></script>
    <script src="./map.js"></script>
    <script type="text/javascript">
      "use script" //开发环境建议开启严格模式

      let measureObj

      function initUI(options) {
        $("#clearAll").click(() => {
          removeAll()

          $("#sectionChars").hide()
          myChart1.clear()
        })

        // 图表自适应
        window.addEventListener("resize", function () {
          myChart1.resize()
        })
      }

      eventTarget.on("measureEnd", function (event) {
        setEchartsData(event)
      })

      eventTarget.on("measureClick", function (event) {
        if (event.value) {
          setEchartsData(event.value)
        }
      })

      let myChart1

      //剖面分析 图表
      function setEchartsData(data) {
        if (data == null || data.arrPoint == null) {
          return
        }
        const arrPoint = data.arrPoint
        let inhtml = ""

        $("#sectionChars").show()
        if (myChart1 == null) {
          myChart1 = echarts.init(document.getElementById("echartsView1"), "dark")
        }

        const option = {
          grid: {
            left: 10,
            right: 40,
            bottom: 10,
            top: 40,
            containLabel: true
          },
          dataZoom: [
            {
              type: "inside",
              throttle: 50
            }
          ],
          tooltip: {
            trigger: "axis",
            // position: function (point, params, dom, rect, size) {
            //    return [10, 20];
            // },
            formatter: (params) => {
              if (params.length === 0) {
                hideTipMarker()
                return inhtml
              }

              const hbgd = params[0].value // 海拔高度
              const point = arrPoint[params[0].dataIndex] // 所在经纬度
              const len = formatDistance(Number(params[0].axisValue))
              const hbgdStr1 = formatDistance(Number(params[0].value)) || "无"
              const hbgdStr2 = formatDistance(Number(params[1].value)) || "无"
              const hbgdStr3 = formatDistance(Number(params[2].value)) || "无"

              inhtml = `当前位置<br />
        距起点：${len}<br />
        C1高度：<span style='color:${params[0].color};'>${hbgdStr1}</span><br />
        C2高度：<span style='color:${params[1].color};'>${hbgdStr2}</span><br />
        C3高度：<span style='color:${params[2].color};'>${hbgdStr3}</span><br />
        经度：${point.lng}<br />
        纬度：${point.lat}`

              showTipMarker(point, hbgd, inhtml)

              return inhtml
            }
          },
          xAxis: [
            {
              name: "长度",
              type: "category",
              nameTextStyle: { color: "rgb(255, 70, 131)" },
              boundaryGap: false,
              axisLine: {
                show: true
              },
              axisLabel: {
                show: true,
                formatter: "{value} 米",
                color: "#fff"
              },
              data: data.arrLen
            }
          ],
          yAxis: [
            {
              name: "高程",
              nameTextStyle: { color: "rgb(255, 70, 131)" },
              type: "value",
              min: 0, // getMinZ(arrPoint),
              axisLabel: {
                formatter: "{value} 米",
                color: "#fff"
              }
            }
          ],
          series: [
            {
              name: "C1高度",
              type: "line",
              smooth: true,
              itemStyle: {
                normal: {
                  color: "#698d29"
                }
              },
              data: data.arrHB1
            },
            {
              name: "C2高度",
              type: "line",
              smooth: true,
              itemStyle: {
                normal: {
                  color: "#782b71"
                }
              },
              data: data.arrHB2
            },
            {
              name: "C3高度",
              type: "line",
              smooth: true,
              itemStyle: {
                normal: {
                  color: "#332d91"
                }
              },
              data: data.arrHB3
            }
          ]
        }

        myChart1.setOption(option)
        myChart1.resize()
      }
    </script>
  </body>
</html>
